$(function() {
	$('li.headlink').on('mouseover', function() {
		$('ul', this).css('display', 'block');
		$(this).children('a').addClass('hovering');
	});
	$('li.headlink').on('mouseout', function() {
		$('ul', this).css('display', 'none');
		$(this).children('a').removeClass('hovering');
	});
	$('li.headlink>ul>li').on('mouseover', function() {
		$(this).addClass('subHovering');
	});
	$('li.headlink>ul>li').on('mouseout', function() {
		$(this).removeClass('subHovering');
	});

	$('#churchDescriptionContainer .churchDescription ').on('mouseover', function() {
		$('#churchDescriptionVerses .verseContainer').hide();
		$('#churchDescriptionVerses .verseContainer').eq($(this).parent().index()).fadeIn();
	});
});

function GetUrlArg(paramName){
    var searchString = window.location.search.substring(1);
    var paramArgArray = searchString.split('&');
    for(var i = 0; i < paramArgArray.length; ++i){
        var paramArgPair = paramArgArray[i].split('=');
        if(paramArgPair[0] == paramName){
            return paramArgPair[1];
        }
    }
}

function hasClass(ele, cls) {
    return ele.className.match(new RegExp('\\s*' + cls + '\\s*'));
}
function addClass(ele, cls) {
    if (!hasClass(ele, cls)) {
    	ele.className += " " + cls;
	}
}
function removeClass(ele, cls) {
    if (hasClass(ele, cls)) {
        var reg = new RegExp('\\s*' + cls + '\\s*');
        ele.className = ele.className.replace(reg, ' ');
    }
}